home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume4 / dragon / patch1.2 < prev    next >
Encoding:
Internet Message Format  |  1989-05-23  |  32.7 KB

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v04i006:  Dragon, Patch1 (Part2)
  5. Message-ID: <767@island.uu.net>
  6. Date: 24 May 89 07:40:49 GMT
  7. Organization: Island Graphics, Marin County, California
  8. Lines: 1001
  9. Approved: island!argv@sun.com
  10.  
  11. Submitted-by: Gary Barnes <uunet!igor!amber!geb>
  12. Posting-number: Volume 4, Issue 6
  13. Archive-name: Dragon/patch1 (Part2)
  14.  
  15. *** ../dragon/Imakefile    Tue May 23 00:05:20 1989
  16. --- Imakefile    Mon May 22 23:55:26 1989
  17. ***************
  18. *** 1,7 ****
  19. !            SRCS = main.c board.c button.c icon.c tile.c tile_bits.c
  20. !            OBJS = main.o board.o button.o icon.o tile.o tile_bits.o
  21.          PROGRAMS = dragon
  22. !         DEFINES =
  23.          INCLUDES = 
  24.     SYS_LIBRARIES = -lXaw -lXmu -lXt -lX11
  25.   
  26. --- 1,8 ----
  27. !            SRCS = main.c board.c button.c draw.c icon.c tile.c tile_bits.c
  28. !            OBJS = main.o board.o button.o draw.o icon.o tile.o tile_bits.o
  29.          PROGRAMS = dragon
  30. !        LINTOPTS = -uxz
  31. !         DEFINES = -DWANTDEBUG
  32.          INCLUDES = 
  33.     SYS_LIBRARIES = -lXaw -lXmu -lXt -lX11
  34.   
  35. ***************
  36. *** 13,19 ****
  37. --- 14,27 ----
  38.           $(USRLIBDIR)/libXt.a \
  39.           $(USRLIBDIR)/libX11.a
  40.   
  41. + lint:
  42. +     $(LINT) $(LINTFLAGS) $(SRCS)
  43.   MakeBug:
  44.       cp Makefile MakeBug.bak
  45.       make -f MakeBug.bak Makefile
  46.       rm MakeBug.bak
  47. + tar:
  48. +     tar cf - . > ../dragon.tar
  49. +     compress -v ../dragon.tar
  50. *** ../dragon/Makefile    Tue May 23 00:05:21 1989
  51. --- Makefile    Mon May 22 23:55:28 1989
  52. ***************
  53. *** 1,4 ****
  54. !             TOP = /usr/src/X11R3
  55.           UTILSRC = $(TOP)/util
  56.          IMAKESRC = $(UTILSRC)/imake
  57.             IMAKE = $(IMAKESRC)/imake
  58. --- 1,4 ----
  59. !             TOP = /src/x
  60.           UTILSRC = $(TOP)/util
  61.          IMAKESRC = $(UTILSRC)/imake
  62.             IMAKE = $(IMAKESRC)/imake
  63. *** ../dragon/README    Tue May 23 00:03:36 1989
  64. --- README    Mon May 22 23:55:30 1989
  65. ***************
  66. *** 1,9 ****
  67. ! 04/19/89
  68.   
  69.   Dragon is a game.  It implements a version of the ancient game of Mah-Jongg.
  70.   
  71. ! Dragon is known to work on a Sun 3/60 running SunOS 3.5 with X11R3 from MIT.
  72. ! It compiles with the Sun compiler and with gcc version 1.31.
  73.   
  74.   As of this writing, the Athena Dialog widget has a bug that can cause Dragon
  75.   to get a segmentation/memory error.  There is code in X11R3/lib/Xaw/Dialog.c
  76. --- 1,24 ----
  77. ! 05/18/89
  78.   
  79.   Dragon is a game.  It implements a version of the ancient game of Mah-Jongg.
  80.   
  81. ! Dragon is known to work on a Sun 3/60 running SunOS 3.5 with X11R3 from
  82. ! MIT.  It compiles with the Sun compiler and with gcc version 1.31.
  83. ! I have been told that the current version (this one right here) runs
  84. ! correctly on monochrome, gray-scale, and color DEC equipment.  Presumably
  85. ! it will run correctly on most servers at this point.
  86. ! Dragon is a "monochrome" application; it uses two colors; the default
  87. ! "foreground" color and the default "background" color as defined and
  88. ! determined by the X Toolkit.
  89. ! If you do a "make all" initially then the Makefile will be rebuilt using
  90. ! the MIT imake program.  If you do not have the MIT imake program (or don't
  91. ! want to use it) then rename the Makefile.Canned file to be Makefile and
  92. ! hand-edit it for use at your site.
  93. ! 04/19/89
  94.   
  95.   As of this writing, the Athena Dialog widget has a bug that can cause Dragon
  96.   to get a segmentation/memory error.  There is code in X11R3/lib/Xaw/Dialog.c
  97. *** ../dragon/button.c    Tue May 23 00:04:00 1989
  98. --- button.c    Mon May 22 23:55:36 1989
  99. ***************
  100. *** 4,9 ****
  101. --- 4,12 ----
  102.   * Author: Gary E. Barnes    March 1989
  103.   *
  104.   * button.c - Deals with the command buttons on the board
  105. + ******************************************************************************
  106. + *  4/24/89 GEB     - When "Other" pressed, if "Samples" is on then turn it off
  107. + *        -  before changing button menus.
  108.   ******************************************************************************/
  109.   
  110.   #include "main.h"
  111. ***************
  112. *** 57,62 ****
  113. --- 60,66 ----
  114.       { "New Game",   New_Game,      FALSE   },
  115.       { "Restart",    Restart_Game, FALSE  },
  116.       { "Save",        Save_Game,    FALSE   },
  117. + #define OTHER_BUTTON 3
  118.       { "Other",        Other,      TRUE    },
  119.   
  120.       { "Hint",        Hints,      FALSE   },
  121. ***************
  122. *** 68,73 ****
  123. --- 72,78 ----
  124.   Button_Rec    Buttons2[NBUTTONS] = {
  125.       { "Redraw",        Redraw_All,      FALSE   },
  126.       { "Sides",        Sides,      FALSE   },
  127. + #define SAMPLES_BUTTON 2
  128.       { "Samples",    Show_Samples, TRUE    },
  129.       { "Other",        Other,      TRUE    },
  130.   
  131. ***************
  132. *** 107,114 ****
  133.   {
  134.   #undef SETARG
  135.   #define SETARG(name,value) \
  136. !     if (argi >= XtNumber(args)) {fprintf(stderr,"BS args overrun!\n");} \
  137. !     XtSetArg( args[argi], name,  value ); ++argi;
  138.   
  139.       Arg        args[10];
  140.       int        argi;
  141. --- 112,119 ----
  142.   {
  143.   #undef SETARG
  144.   #define SETARG(name,value) \
  145. !     DEBUG_ERROR(argi >= XtNumber(args),"BS args overrun!\n" ); \
  146. !     XtSetArg( args[argi], name,  (XtArgVal)value ); ++argi;
  147.   
  148.       Arg        args[10];
  149.       int        argi;
  150. ***************
  151. *** 218,226 ****
  152.       if (All_Buttons == &Buttons1[0]) {
  153.       All_Buttons = &Buttons2[0];
  154.       } else {
  155.       All_Buttons = &Buttons1[0];
  156.       }
  157. !     All_Buttons[3].hilite = !All_Buttons[3].hilite;
  158.       XClearArea( XtDisplay(Board), XtWindow(w),
  159.               0, 0, 0, (unsigned)(2*Tile_Height-Side_Y-Shadow_Y-1), FALSE );
  160.       Button_Expose( w, event, params, num_params );
  161. --- 223,236 ----
  162.       if (All_Buttons == &Buttons1[0]) {
  163.       All_Buttons = &Buttons2[0];
  164.       } else {
  165. +     /*--Turn off Samples mode if we are changing menus. */
  166. +     if (Buttons2[SAMPLES_BUTTON].hilite) {
  167. +         (*(Buttons2[SAMPLES_BUTTON].action))(w, event, params, num_params);
  168. +         Buttons2[SAMPLES_BUTTON].hilite = FALSE;
  169. +     }
  170.       All_Buttons = &Buttons1[0];
  171.       }
  172. !     All_Buttons[OTHER_BUTTON].hilite = !All_Buttons[OTHER_BUTTON].hilite;
  173.       XClearArea( XtDisplay(Board), XtWindow(w),
  174.               0, 0, 0, (unsigned)(2*Tile_Height-Side_Y-Shadow_Y-1), FALSE );
  175.       Button_Expose( w, event, params, num_params );
  176. ***************
  177. *** 259,266 ****
  178.       FILE    *file;
  179.   
  180.       DEBUG_CALL(Restore_Game);
  181. !     strcpy( &name[0], getenv( "HOME" ) );
  182. !     strcat( &name[0], "/.dragon-save" );
  183.       file = fopen( &name[0], "r" );
  184.       if (file == (FILE*)NULL) {
  185.       Complain( "Cannot open the $HOME/.dragon-save file." );
  186. --- 269,276 ----
  187.       FILE    *file;
  188.   
  189.       DEBUG_CALL(Restore_Game);
  190. !     (void)strcpy( &name[0], getenv( "HOME" ) );
  191. !     (void)strcat( &name[0], "/.dragon-save" );
  192.       file = fopen( &name[0], "r" );
  193.       if (file == (FILE*)NULL) {
  194.       Complain( "Cannot open the $HOME/.dragon-save file." );
  195. ***************
  196. *** 289,296 ****
  197.       FILE    *file;
  198.   
  199.       DEBUG_CALL(Save_Game);
  200. !     strcpy( &name[0], getenv( "HOME" ) );
  201. !     strcat( &name[0], "/.dragon-save" );
  202.       file = fopen( &name[0], "w" );
  203.       if (file == (FILE*)NULL) {
  204.       Complain( "Cannot open the $HOME/.dragon-save file." );
  205. --- 299,306 ----
  206.       FILE    *file;
  207.   
  208.       DEBUG_CALL(Save_Game);
  209. !     (void)strcpy( &name[0], getenv( "HOME" ) );
  210. !     (void)strcat( &name[0], "/.dragon-save" );
  211.       file = fopen( &name[0], "w" );
  212.       if (file == (FILE*)NULL) {
  213.       Complain( "Cannot open the $HOME/.dragon-save file." );
  214. ***************
  215. *** 401,408 ****
  216.           if (but[i].text == NULL) { goto Next_Button; }
  217.           l = strlen(but[i].text);
  218.           if (l > 8) {
  219. !         fprintf( stderr, "Button name too long: %s\n",
  220. !              but[i].text );
  221.           l = 8;
  222.           }
  223.           but[i].x = x;
  224. --- 411,418 ----
  225.           if (but[i].text == NULL) { goto Next_Button; }
  226.           l = strlen(but[i].text);
  227.           if (l > 8) {
  228. !         (void)fprintf( stderr, "Button name too long: %s\n",
  229. !                    but[i].text );
  230.           l = 8;
  231.           }
  232.           but[i].x = x;
  233. ***************
  234. *** 463,469 ****
  235.   * Called to draw the vector text in some button.
  236.   ******************************************************************************/
  237.   {
  238. !     static char pntserr[] = "DT pnts overflow!\n";
  239.       XPoint    pnts[50];
  240.       int        pnti;
  241.       int        h1;
  242. --- 473,481 ----
  243.   * Called to draw the vector text in some button.
  244.   ******************************************************************************/
  245.   {
  246. ! #ifdef WANTDEBUG
  247. !     static char *pntserr = "DT pnts overflow!\n";
  248. ! #endif
  249.       XPoint    pnts[50];
  250.       int        pnti;
  251.       int        h1;
  252. ***************
  253. *** 471,477 ****
  254.   
  255.   #undef PNT
  256.   #define PNT(X,Y) \
  257. !     if (pnti >= XtNumber(pnts)){fprintf(stderr,pntserr);} \
  258.       pnts[pnti].x = X; pnts[pnti].y = Y; ++pnti
  259.       ;
  260.   
  261. --- 483,489 ----
  262.   
  263.   #undef PNT
  264.   #define PNT(X,Y) \
  265. !     DEBUG_ERROR( pnti >= XtNumber(pnts), pntserr ); \
  266.       pnts[pnti].x = X; pnts[pnti].y = Y; ++pnti
  267.       ;
  268.   
  269. ***************
  270. *** 500,512 ****
  271.           PNT( 0,        h26    );
  272.           PNT( w6,    h6    );
  273.           PNT( w6,    h6    );
  274. !         PNT( 2*w6,    0    );
  275.           PNT( w6,    -h6    );
  276.           PNT( w6,    -h6    );
  277.           PNT( 0,        -h26    );
  278.           PNT( -w6,    -h6    );
  279.           PNT( -w6,    -h6    );
  280. !         PNT( -2*w6,    0    );
  281.           PNT( -w6,    h6    );
  282.           PNT( -w6,    h6    );
  283.           break;
  284. --- 512,524 ----
  285.           PNT( 0,        h26    );
  286.           PNT( w6,    h6    );
  287.           PNT( w6,    h6    );
  288. !         PNT( w1-4*w6,    0    );
  289.           PNT( w6,    -h6    );
  290.           PNT( w6,    -h6    );
  291.           PNT( 0,        -h26    );
  292.           PNT( -w6,    -h6    );
  293.           PNT( -w6,    -h6    );
  294. !         PNT( -(w1-4*w6),0    );
  295.           PNT( -w6,    h6    );
  296.           PNT( -w6,    h6    );
  297.           break;
  298. *** ../dragon/dragon.man    Tue May 23 00:03:54 1989
  299. --- dragon.man    Mon May 22 23:55:37 1989
  300. ***************
  301. *** 8,16 ****
  302. --- 8,18 ----
  303.   [-icongeometry geometry]
  304.   [-/+iconic]
  305.   [-iconname name]
  306. + [-geometry geometry]
  307.   [-/+reverse]
  308.   [-/+shadows]
  309.   [-sides type]
  310. + [-/+sticky]
  311.   .SH DESCRIPTION
  312.   \fIDragon\fP plays a version of the game of Mah-Jongg.
  313.   
  314. ***************
  315. *** 73,78 ****
  316. --- 75,85 ----
  317.   250 milliseconds.  Clicks further apart than this will be treated as
  318.   separate single clicks instead of one double click.
  319.   .TP 8
  320. + .B \-geometry geometry
  321. + Use this option to specify the geometry to be used for the
  322. + \fIdragon\fP window.  There are five sizes that \fIdragon\fP prefers,
  323. + 450x340, 650x500, 870x660, 1080x820, and 1290x980.
  324. + .TP 8
  325.   .B \-icongeometry geometry
  326.   Use this option to specify the geometry to be used for the
  327.   \fIdragon\fP icon.  There are two sizes that \fIdragon\fP prefers,
  328. ***************
  329. *** 97,102 ****
  330. --- 104,116 ----
  331.   .B \-sides type
  332.   This option can be used to specify the way that tile sides are drawn.
  333.   There are four possiblities.  "gray" (the default), "black", and "line".
  334. + .TP 8
  335. + .B \-sticky
  336. + By default, the first selection is "sticky" (+sticky) which means that
  337. + attempts to select a second tile that is free but which doesn't match
  338. + the first are rejected.  If the first selection is not sticky
  339. + (-sticky), an attempt to select a free tile that doesn't match the first
  340. + will deselect the first tile and leave only the second selected.
  341.   .SH MOUSE BUTTONS
  342.   Click button 1 on any tile to select it.  Click on any menu button to activate
  343.   it.
  344. ***************
  345. *** 176,181 ****
  346. --- 190,201 ----
  347.   Specifies the maximum time to allow between the two clicks that form a
  348.   double-click.  The default is 250.
  349.   .TP 8
  350. + .B "geometry (\fPclass\fB Geometry)"
  351. + Use this option to specify the geometry to be used for the
  352. + \fIdragon\fP window.  There are five sizes that \fIdragon\fP prefers,
  353. + 450x340, 650x500, 870x660, 1080x820, and 1290x980.  The default is
  354. + "450x340".
  355. + .TP 8
  356.   .B "iconGeometry (\fPclass\fB IconGeometry)"
  357.   Specifies the geometry of the \fIdragon\fB icon.  Preferred sizes are
  358.   32x32 and 64x64.  The default is "64x64".
  359. ***************
  360. *** 190,195 ****
  361. --- 210,219 ----
  362.   .B "reverseVideo (\fPclass\fB ReverseVideo)"
  363.   Specifies TRUE for reverse-video effects and FALSE for normal-video.
  364.   The default is FALSE.
  365. + .TP 8
  366. + .B "stickyTile \(fPclass\fB StickyTile)|
  367. + Specify TRUE for first tile selected to be sticky (default), FALSE for
  368. + selection follows click.
  369.   .TP 8
  370.   .B "tileShadows (\fPclass\fB TileShadows)"
  371.   Specifies TRUE if tiles are to have 3-D shadows and FALSE if not.  The
  372. *** ../dragon/icon.c    Tue May 23 00:04:01 1989
  373. --- icon.c    Mon May 22 23:55:41 1989
  374. ***************
  375. *** 13,19 ****
  376.   
  377.   extern char * malloc();
  378.   extern        free();
  379. - extern Pixmap XCreateTile();
  380.   
  381.   
  382.   GC    Icon_GC = (GC)0;        /* GC used for Icon window. */
  383. --- 13,18 ----
  384. ***************
  385. *** 58,70 ****
  386.    *  preexisting Icon images. */
  387.   
  388.       if (Icon_GC == (GC)0) {
  389. !     if (Dragon_Resources.Reverse_Video) {
  390. !         gcv.background = BlackPixelOfScreen(XtScreen(w));
  391. !         gcv.foreground = WhitePixelOfScreen(XtScreen(w));
  392. !     } else {
  393. !         gcv.foreground = BlackPixelOfScreen(XtScreen(w));
  394. !         gcv.background = WhitePixelOfScreen(XtScreen(w));
  395. !     }
  396.       Icon_GC = XtGetGC( w, GCForeground|GCBackground, &gcv );
  397.       }
  398.       ximage.height  = size;
  399. --- 57,64 ----
  400.    *  preexisting Icon images. */
  401.   
  402.       if (Icon_GC == (GC)0) {
  403. !     gcv.foreground = Dragon_Resources.Foreground;
  404. !     gcv.background = Dragon_Resources.Background;
  405.       Icon_GC = XtGetGC( w, GCForeground|GCBackground, &gcv );
  406.       }
  407.       ximage.height  = size;
  408. ***************
  409. *** 115,122 ****
  410.       int           scr;
  411.   
  412.   #define SETARG(name,value) \
  413. !     if (*argi >= argn) {fprintf(stderr,"IS args overrun!\n");} \
  414. !     XtSetArg( args[*argi], name,  value ); ++*argi;
  415.   
  416.   /*--If we've been asked to set up the Icon geometry then do that. */
  417.   
  418. --- 109,116 ----
  419.       int           scr;
  420.   
  421.   #define SETARG(name,value) \
  422. !     DEBUG_ERROR( *argi >= argn, "IS args overrun!\n" ); \
  423. !     XtSetArg( args[*argi], name,  (XtArgVal)value ); ++*argi;
  424.   
  425.   /*--If we've been asked to set up the Icon geometry then do that. */
  426.   
  427. ***************
  428. *** 172,183 ****
  429.               ic[i].min_height <= size &&
  430.               size-ic[i].min_height & ic[i].height_inc == 0) {
  431.               Icon_Pixmap =        /* Size is perfect */
  432. !               XCreateTile( XtDisplay(Dragon),
  433. !                    RootWindowOfScreen(XtScreen(Dragon)),
  434. !                    (size == 64
  435. !                     ? &dragon_icon64_bits[0]
  436. !                     : &dragon_icon32_bits[0]), 
  437. !                    size, size );
  438.           }
  439.           }
  440.           if (Icon_Pixmap != (Pixmap)NULL ||     /* Stop on success */
  441. --- 166,181 ----
  442.               ic[i].min_height <= size &&
  443.               size-ic[i].min_height & ic[i].height_inc == 0) {
  444.               Icon_Pixmap =        /* Size is perfect */
  445. !               XCreatePixmapFromBitmapData
  446. !             ( XtDisplay(Dragon),
  447. !               RootWindowOfScreen(XtScreen(Dragon)),
  448. !               (size == 64
  449. !                ? &dragon_icon64_bits[0]
  450. !                : &dragon_icon32_bits[0]), 
  451. !               (unsigned int)size, (unsigned int)size,
  452. !               Dragon_Resources.Foreground,
  453. !               Dragon_Resources.Background,
  454. !               DefaultDepthOfScreen(XtScreen(Dragon)) );
  455.           }
  456.           }
  457.           if (Icon_Pixmap != (Pixmap)NULL ||     /* Stop on success */
  458. ***************
  459. *** 193,199 ****
  460.           char    *data;
  461.           char    *orig;
  462.           char    *ptr;
  463. !         int         w, wb, h, hb;
  464.           int         inc;
  465.   
  466.   /*--Figure out which of our pixmaps we will copy into this odd pixmap. */
  467. --- 191,197 ----
  468.           char    *data;
  469.           char    *orig;
  470.           char    *ptr;
  471. !         unsigned int w, wb, h, hb;
  472.           int         inc;
  473.   
  474.   /*--Figure out which of our pixmaps we will copy into this odd pixmap. */
  475. ***************
  476. *** 235,243 ****
  477.   /*--Create the pixmap and free up the data area. */
  478.   
  479.           Icon_Pixmap =
  480. !           XCreateTile( XtDisplay(Dragon),
  481. !                RootWindowOfScreen(XtScreen(Dragon)),
  482. !                data, w, h );
  483.           free( data );
  484.       }
  485.       XFree( ic );
  486. --- 233,243 ----
  487.   /*--Create the pixmap and free up the data area. */
  488.   
  489.           Icon_Pixmap =
  490. !           XCreatePixmapFromBitmapData
  491. !         ( XtDisplay(Dragon), RootWindowOfScreen(XtScreen(Dragon)),
  492. !           data, w, h,
  493. !           Dragon_Resources.Foreground, Dragon_Resources.Background,
  494. !           DefaultDepthOfScreen(XtScreen(Dragon)) );
  495.           free( data );
  496.       }
  497.       XFree( ic );
  498. ***************
  499. *** 262,270 ****
  500.       Widget        Icon_Core;
  501.   
  502.   #define LCLARG(name,value) \
  503. !     if (SomeArgsi >= XtNumber(SomeArgs)) \
  504. !       {fprintf(stderr,"IS SomeArgs overrun!\n");} \
  505. !     XtSetArg( SomeArgs[SomeArgsi], name,  value ); ++SomeArgsi;
  506.           ;
  507.   
  508.   /*--Create a shell to contain the Icon window. */
  509. --- 262,270 ----
  510.       Widget        Icon_Core;
  511.   
  512.   #define LCLARG(name,value) \
  513. !     DEBUG_ERROR( SomeArgsi >= XtNumber(SomeArgs), \
  514. !              "IS SomeArgs overrun!\n" ); \
  515. !     XtSetArg( SomeArgs[SomeArgsi], name,  (XtArgVal)value ); ++SomeArgsi;
  516.           ;
  517.   
  518.   /*--Create a shell to contain the Icon window. */
  519. *** ../dragon/main.c    Tue May 23 00:04:03 1989
  520. --- main.c    Mon May 22 23:55:43 1989
  521. ***************
  522. *** 38,57 ****
  523.        XtRString, (caddr_t)default}
  524.   #define INT(name,class,field,default) \
  525.       {name, class, XtRInt, sizeof(int), offset(field), XtRInt, (caddr_t)default}
  526.   #define STRING(name,class,field,default) \
  527.       {name, class, XtRString, sizeof(String), offset(field), XtRString, \
  528.        (caddr_t)default}
  529.   
  530.   static XtResource dragon_resources[] = {
  531.     CURSOR ( "cursor",        XtCCursor,       Cursor,             "hand2"     ),
  532.     BOOLEAN( "debug",        "Debug",         Debug,         &def_FALSE  ),
  533.     INT    ( "doubleClick",   "DoubleClick",   Double_Click_Time,  &def_DCTime ),
  534. !   STRING ( XtNgeometry,     XtCGeometry,     Geometry,         "444x339"   ),
  535.     STRING ( "iconGeometry",  "IconGeometry",  Icon_Geometry,      "64x64"     ),
  536.     BOOLEAN( "iconic",        "Iconic",        Iconic,             &def_FALSE  ),
  537.     STRING ( XtNiconName,        XtCIconName,     Icon_Name,         NULL          ),
  538.     BOOLEAN( XtNreverseVideo, XtCReverseVideo, Reverse_Video,      &def_FALSE  ),
  539. !   BOOLEAN( "tileShadows",   "TileShadows",   Tile_Shadows,     &def_TRUE  ),
  540.     STRING ( "tileSides",        "TileSides",     Tile_Sides,     "gray"         ),
  541.   };
  542.   
  543. --- 38,65 ----
  544.        XtRString, (caddr_t)default}
  545.   #define INT(name,class,field,default) \
  546.       {name, class, XtRInt, sizeof(int), offset(field), XtRInt, (caddr_t)default}
  547. + #define PIXEL(name,class,field,default) \
  548. +     {name, class, XtRPixel, sizeof(Pixel), \
  549. +      offset(field), XtRString, (caddr_t)default}
  550.   #define STRING(name,class,field,default) \
  551.       {name, class, XtRString, sizeof(String), offset(field), XtRString, \
  552.        (caddr_t)default}
  553.   
  554.   static XtResource dragon_resources[] = {
  555. +   PIXEL  ( XtNbackground,   XtCBackground,   Background,
  556. +        XtExtdefaultbackground ),
  557.     CURSOR ( "cursor",        XtCCursor,       Cursor,             "hand2"     ),
  558.     BOOLEAN( "debug",        "Debug",         Debug,         &def_FALSE  ),
  559.     INT    ( "doubleClick",   "DoubleClick",   Double_Click_Time,  &def_DCTime ),
  560. !   PIXEL  ( XtNforeground,   XtCForeground,   Foreground,
  561. !        XtExtdefaultforeground ),
  562. !   STRING ( XtNgeometry,     XtCGeometry,     Geometry,         "450x340"   ),
  563.     STRING ( "iconGeometry",  "IconGeometry",  Icon_Geometry,      "64x64"     ),
  564.     BOOLEAN( "iconic",        "Iconic",        Iconic,             &def_FALSE  ),
  565.     STRING ( XtNiconName,        XtCIconName,     Icon_Name,         NULL          ),
  566.     BOOLEAN( XtNreverseVideo, XtCReverseVideo, Reverse_Video,      &def_FALSE  ),
  567. !   BOOLEAN( "stickyTile",    "StickyTile",    Sticky_Tile,     &def_TRUE   ),
  568. !   BOOLEAN( "tileShadows",   "TileShadows",   Tile_Shadows,     &def_TRUE   ),
  569.     STRING ( "tileSides",        "TileSides",     Tile_Sides,     "gray"         ),
  570.   };
  571.   
  572. ***************
  573. *** 80,85 ****
  574. --- 88,95 ----
  575.   {"-shadows",     ".tileShadows",     XrmoptionNoArg,   (caddr_t)"off"  },
  576.   {"+shadows",     ".tileShadows",     XrmoptionNoArg,   (caddr_t)"on" },
  577.   {"-sides",     ".tileSides",         XrmoptionSepArg,  (caddr_t)"line"},
  578. + {"-sticky",     ".stickyTile",      XrmoptionNoArg,   (caddr_t)"off" },
  579. + {"+sticky",     ".stickyTile",      XrmoptionNoArg,   (caddr_t)"on" },
  580.   };
  581.   
  582.   typedef struct {
  583. ***************
  584. *** 100,105 ****
  585. --- 110,116 ----
  586.   {"-/+reverse",         "turn on/off reverse video"},
  587.   {"-/+shadows",         "turn on/off tile shadows"},
  588.   {"-sides line/black/gray","set the style for tile sides"},
  589. + {"-/+sticky",         "first tile selected sticky"},
  590.   { NULL, NULL }
  591.   };
  592.   
  593. ***************
  594. *** 157,195 ****
  595.   } /* Command_Line_Help */
  596.   
  597.   
  598. - Pixmap XCreateTile( display, d, data, width, height )
  599. -      Display        *display;
  600. -      Drawable         d;
  601. -      char        *data;
  602. -      unsigned int    width, height;
  603. - /******************************************************************************
  604. - * Converted form of XCreatePixmapFromBitmapData.  Use our GC and don't bother
  605. - * the Server for another one.
  606. - ******************************************************************************/
  607. - {
  608. -     XImage ximage;
  609. -     Pixmap pix;
  610. -     pix = XCreatePixmap( display, d, width, height, 1 );
  611. -     if (pix == (Pixmap)0) return (Pixmap)0;
  612. -     ximage.height = height;
  613. -     ximage.width = width;
  614. -     ximage.depth = 1;
  615. -     ximage.xoffset = 0;
  616. -     ximage.format = XYBitmap;
  617. -     ximage.data = data;
  618. -     ximage.byte_order = LSBFirst;
  619. -     ximage.bitmap_unit = 8;
  620. -     ximage.bitmap_bit_order = LSBFirst;
  621. -     ximage.bitmap_pad = 8;
  622. -     ximage.bytes_per_line = (width+7)/8;
  623. -     XPutImage( display, pix, Normal_GC, &ximage, 0, 0, 0, 0, width, height );
  624. -     return pix;
  625. - } /* XCreateTile */
  626.   static void GC_Setup()
  627.   /******************************************************************************
  628.   * Set up the GC's that we will be using for drawing.
  629. --- 168,173 ----
  630. ***************
  631. *** 198,208 ****
  632.       XGCValues    gcv;
  633.       Pixel    pix;
  634.   
  635. ! /*--Xor_GC - fg = black, bg = white, func = xor */
  636.   
  637.       gcv.function = GXxor;
  638. !     gcv.foreground = BlackPixelOfScreen(XtScreen(Dragon));
  639. !     gcv.background = WhitePixelOfScreen(XtScreen(Dragon));
  640.       Xor_GC = XtGetGC( Dragon,
  641.                 GCFunction|GCForeground|GCBackground,
  642.                 &gcv );
  643. --- 176,187 ----
  644.       XGCValues    gcv;
  645.       Pixel    pix;
  646.   
  647. ! /*--Xor_GC - fg = black, bg = white, func = xor; flops colors between the
  648. !  *  foreground and the background when applied. */
  649.   
  650.       gcv.function = GXxor;
  651. !     gcv.foreground = Dragon_Resources.Foreground ^ Dragon_Resources.Background;
  652. !     gcv.background = (Pixel)0;    /* pixel value with all bits "off" */
  653.       Xor_GC = XtGetGC( Dragon,
  654.                 GCFunction|GCForeground|GCBackground,
  655.                 &gcv );
  656. ***************
  657. *** 210,227 ****
  658.   /*--Normal_GC - fg = black, bg = white, func = copy */
  659.   
  660.       gcv.function = GXcopy;
  661. !     if (Dragon_Resources.Reverse_Video) {
  662. !     gcv.background = BlackPixelOfScreen(XtScreen(Dragon));
  663. !     gcv.foreground = WhitePixelOfScreen(XtScreen(Dragon));
  664. !     }
  665.       Normal_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  666.   
  667.   /*--Gray_GC - fg = black, bg = white, func = copy, tile = Gray */
  668.   
  669. !     gcv.tile = XCreateTile( XtDisplay(Board), XtWindow(Board),
  670. !                 gray_bits, gray_width, gray_height );
  671. !     if (gcv.tile == None) {
  672. !     fprintf( stderr, "Can't allocate gray pixmap.\n" );
  673.       exit(1);
  674.       }
  675.       gcv.fill_style = FillTiled;
  676. --- 189,208 ----
  677.   /*--Normal_GC - fg = black, bg = white, func = copy */
  678.   
  679.       gcv.function = GXcopy;
  680. !     gcv.foreground = Dragon_Resources.Foreground;
  681. !     gcv.background = Dragon_Resources.Background;
  682.       Normal_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  683.   
  684.   /*--Gray_GC - fg = black, bg = white, func = copy, tile = Gray */
  685.   
  686. !     gcv.tile =
  687. !       XCreatePixmapFromBitmapData
  688. !     ( XtDisplay(Board), XtWindow(Board),
  689. !       gray_bits, gray_width, gray_height,
  690. !       Dragon_Resources.Foreground, Dragon_Resources.Background,
  691. !       DefaultDepthOfScreen(XtScreen(Board)) );
  692. !     if (gcv.tile == (Pixmap)0L) {
  693. !     (void)fprintf( stderr, "Can't allocate gray pixmap.\n" );
  694.       exit(1);
  695.       }
  696.       gcv.fill_style = FillTiled;
  697. ***************
  698. *** 229,259 ****
  699.                  GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  700.                  &gcv );
  701.   
  702. ! /*--Over_GC - fg = black, bg = white, func = or */
  703.   
  704. !     if (Dragon_Resources.Reverse_Video) {
  705. !     gcv.function = GXand;
  706. !     } else {
  707. !     gcv.function = GXor;
  708. !     }
  709. !     gcv.tile =
  710. !       XCreateTile( XtDisplay(Board), XtWindow(Board),
  711. !            shadow_bits, shadow_width, shadow_height );
  712. !     if (gcv.tile == None) {
  713. !     fprintf( stderr, "Can't allocate shadow pixmap.\n" );
  714.       exit(1);
  715.       }
  716. !     gcv.fill_style = FillTiled;
  717.       Over_GC = XtGetGC( Dragon,
  718. !                GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  719.                  &gcv );
  720.   
  721.   /*--Reverse_GC - fg = white, bg = black, func = copy */
  722.   
  723.       gcv.function = GXcopy;
  724. !     pix = gcv.background;
  725. !     gcv.background = gcv.foreground;
  726. !     gcv.foreground = pix;
  727.       Reverse_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  728.   
  729.   } /* GC_Setup */
  730. --- 210,237 ----
  731.                  GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  732.                  &gcv );
  733.   
  734. ! /*--Over_GC - fg = black xor white, bg = 0, func = copy */
  735.   
  736. !     gcv.function = GXcopy;
  737. !     gcv.stipple =        /* stipple operations are always depth 1 */
  738. !       XCreateBitmapFromData
  739. !     ( XtDisplay(Board), XtWindow(Board),
  740. !       shadow_bits, shadow_width, shadow_height );
  741. !     if (gcv.stipple == (Pixmap)0L) {
  742. !     (void)fprintf( stderr, "Can't allocate shadow pixmap.\n" );
  743.       exit(1);
  744.       }
  745. !     gcv.fill_style = FillStippled;
  746.       Over_GC = XtGetGC( Dragon,
  747. !                GCFunction|GCForeground|GCBackground|
  748. !                   GCStipple|GCFillStyle,
  749.                  &gcv );
  750.   
  751.   /*--Reverse_GC - fg = white, bg = black, func = copy */
  752.   
  753.       gcv.function = GXcopy;
  754. !     gcv.background = Dragon_Resources.Foreground;
  755. !     gcv.foreground = Dragon_Resources.Background;
  756.       Reverse_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  757.   
  758.   } /* GC_Setup */
  759. ***************
  760. *** 271,278 ****
  761.   
  762.   #undef SETARG
  763.   #define SETARG(name,value) \
  764. !     if (argi >= XtNumber(args)) {fprintf(stderr,"main, args overrun!\n");} \
  765. !     XtSetArg( args[argi], name,  value ); ++argi;
  766.   
  767.   /*--Start up the toolkit.  This creates a shell widget.  Unfortunately the
  768.    *  only way the toolkit allows you to specify default application resources
  769. --- 249,256 ----
  770.   
  771.   #undef SETARG
  772.   #define SETARG(name,value) \
  773. !     DEBUG_ERROR(argi >= XtNumber(args), "main, args overrun!\n" ); \
  774. !     XtSetArg( args[argi], name,  (XtArgVal)value ); ++argi;
  775.   
  776.   /*--Start up the toolkit.  This creates a shell widget.  Unfortunately the
  777.    *  only way the toolkit allows you to specify default application resources
  778. ***************
  779. *** 323,335 ****
  780.       SETARG( XtNmaxAspectX,    1333 );
  781.       SETARG( XtNmaxAspectY,    1000 );
  782.       SETARG( XtNgeometry,    Dragon_Resources.Geometry );
  783. !     if (Dragon_Resources.Reverse_Video) {
  784. !     SETARG( XtNbackground, BlackPixelOfScreen(XtScreen(Dragon)) );
  785. !     SETARG( XtNforeground, WhitePixelOfScreen(XtScreen(Dragon)) );
  786. !     } else {
  787. !     SETARG( XtNforeground, BlackPixelOfScreen(XtScreen(Dragon)) );
  788. !     SETARG( XtNbackground, WhitePixelOfScreen(XtScreen(Dragon)) );
  789. !     }
  790.   
  791.       SETARG( XtNallowShellResize, TRUE );
  792.       SETARG( XtNinput,         TRUE );
  793. --- 301,308 ----
  794.       SETARG( XtNmaxAspectX,    1333 );
  795.       SETARG( XtNmaxAspectY,    1000 );
  796.       SETARG( XtNgeometry,    Dragon_Resources.Geometry );
  797. !     SETARG( XtNforeground, Dragon_Resources.Foreground );
  798. !     SETARG( XtNbackground, Dragon_Resources.Background );
  799.   
  800.       SETARG( XtNallowShellResize, TRUE );
  801.       SETARG( XtNinput,         TRUE );
  802. ***************
  803. *** 352,358 ****
  804.       } else if (strcmp( Dragon_Resources.Tile_Sides, "gray" ) == 0) {
  805.       Tile_Control |= BLACKSIDE | GRAYSIDE;
  806.       } else if (strcmp( Dragon_Resources.Tile_Sides, "line" ) != 0) {
  807. !     fprintf(stderr,"-side option not given line, gray, or black value.\n");
  808.       }
  809.   
  810.   /*--Create the board that we will be using; realize it too. */
  811. --- 325,332 ----
  812.       } else if (strcmp( Dragon_Resources.Tile_Sides, "gray" ) == 0) {
  813.       Tile_Control |= BLACKSIDE | GRAYSIDE;
  814.       } else if (strcmp( Dragon_Resources.Tile_Sides, "line" ) != 0) {
  815. !     (void)fprintf( stderr,
  816. !                "-side option not given line, gray, or black value.\n");
  817.       }
  818.   
  819.   /*--Create the board that we will be using; realize it too. */
  820. ***************
  821. *** 368,378 ****
  822.   /*--Now make it all appear in front of the user. */
  823.   
  824.       {    Pixmap    pix;
  825. !     pix = XCreateTile( XtDisplay(Board), XtWindow(Board),
  826. !                background_bits, background_width,
  827. !                background_height);
  828. !     if (pix == None) {
  829. !         fprintf( stderr, "Can't allocate background pixmap.\n" );
  830.           exit(1);
  831.       }
  832.       XSetWindowBackgroundPixmap( XtDisplay(Board), XtWindow(Board), pix );
  833. --- 342,356 ----
  834.   /*--Now make it all appear in front of the user. */
  835.   
  836.       {    Pixmap    pix;
  837. !     pix =
  838. !       XCreatePixmapFromBitmapData
  839. !         ( XtDisplay(Board), XtWindow(Board),
  840. !           background_bits, background_width, background_height,
  841. !           Dragon_Resources.Foreground, Dragon_Resources.Background,
  842. !           DefaultDepthOfScreen(XtScreen(Board)) );
  843. !                       
  844. !     if (pix == (Pixmap)0L) {
  845. !         (void)fprintf( stderr, "Can't allocate background pixmap.\n" );
  846.           exit(1);
  847.       }
  848.       XSetWindowBackgroundPixmap( XtDisplay(Board), XtWindow(Board), pix );
  849. ***************
  850. *** 384,399 ****
  851.       XtMainLoop();
  852.   
  853.   } /* main */
  854. - #if 0
  855. - */* print out the name of a widget; NOTE: no \n printed so printout is not
  856. - * * flushed until our caller does one. */
  857. - *
  858. - *void spit(w)
  859. - *     Widget    w;
  860. - *{
  861. - *    if (w == NULL) return;
  862. - *    spit( w->core.parent );
  863. - *    fprintf( stderr, ".%s", w->core.name );
  864. - *}
  865. - #endif /* 0 */
  866. --- 362,364 ----
  867. *** ../dragon/main.h    Tue May 23 00:04:05 1989
  868. --- main.h    Mon May 22 23:55:44 1989
  869. ***************
  870. *** 15,22 ****
  871. --- 15,24 ----
  872.   #include <X11/Simple.h>
  873.   #include <X11/StringDefs.h>
  874.   
  875. + #ifndef TRUE
  876.   #define TRUE    1
  877.   #define FALSE    0
  878. + #endif
  879.   
  880.   #ifdef _MAIN_C_
  881.   #define VAR(A)        A
  882. ***************
  883. *** 32,37 ****
  884. --- 34,41 ----
  885.   ******************************************************************************/
  886.   
  887.   typedef struct _Dragon_Resources_Rec{
  888. +     Pixel        Foreground;        /* Default foreground color */
  889. +     Pixel        Background;        /* Default background color */
  890.       Cursor        Cursor;            /* Name of cursor to use */
  891.       Boolean        Debug;            /* Debug printouts */
  892.       int            Double_Click_Time;    /* Time (ms) between clicks */
  893. ***************
  894. *** 40,61 ****
  895.       Boolean        Iconic;            /* Do we start as an icon? */
  896.       String        Icon_Name;        /* Name for the icon */
  897.       Boolean        Reverse_Video;        /* Do all in reverse? */
  898.       Boolean        Tile_Shadows;        /* Want shadows? */
  899.       String        Tile_Sides;        /* What side type? */
  900.   } Dragon_Resources_Rec, *Dragon_Resources_Ptr;
  901.   
  902.   #define DEBUG_CALL(Name) \
  903.     if (Dragon_Resources.Debug) { \
  904. !     fprintf( stderr, "Name call\n" ); fflush(stderr); \
  905.     }
  906.   #define DEBUG_RETURN(Name) \
  907.     if (Dragon_Resources.Debug) { \
  908. !     fprintf( stderr, "Name return\n" ); fflush(stderr); \
  909.     }
  910.   #define DEBUG_OTHER(Name,Other) \
  911.     if (Dragon_Resources.Debug) { \
  912. !     fprintf( stderr, "Name Other\n" ); fflush(stderr); \
  913.     }
  914.   
  915.   /******************************************************************************
  916.   * Bitmap/Image Initialization Structure
  917. --- 44,75 ----
  918.       Boolean        Iconic;            /* Do we start as an icon? */
  919.       String        Icon_Name;        /* Name for the icon */
  920.       Boolean        Reverse_Video;        /* Do all in reverse? */
  921. +     Boolean        Sticky_Tile;        /* Is first tile sticky? */
  922.       Boolean        Tile_Shadows;        /* Want shadows? */
  923.       String        Tile_Sides;        /* What side type? */
  924.   } Dragon_Resources_Rec, *Dragon_Resources_Ptr;
  925.   
  926. + #ifdef WANTDEBUG
  927.   #define DEBUG_CALL(Name) \
  928.     if (Dragon_Resources.Debug) { \
  929. !     (void)fprintf( stderr, "Name call\n" ); (void)fflush(stderr); \
  930.     }
  931.   #define DEBUG_RETURN(Name) \
  932.     if (Dragon_Resources.Debug) { \
  933. !     (void)fprintf( stderr, "Name return\n" ); (void)fflush(stderr); \
  934.     }
  935.   #define DEBUG_OTHER(Name,Other) \
  936.     if (Dragon_Resources.Debug) { \
  937. !     (void)fprintf( stderr, "Name Other\n" ); (void)fflush(stderr); \
  938.     }
  939. + #define DEBUG_ERROR(Test,Msg) \
  940. +   if (Test) { (void)fprintf(stderr,Msg); (void)fflush(stderr); }
  941. + #else
  942. + #define DEBUG_CALL(Name)
  943. + #define DEBUG_RETURN(Name)
  944. + #define DEBUG_OTHER(Name,Other)
  945. + #define DEBUG_ERROR(Test,Msg)
  946. + #endif /* WANTDEBUG */
  947.   
  948.   /******************************************************************************
  949.   * Bitmap/Image Initialization Structure
  950. ***************
  951. *** 96,98 ****
  952. --- 110,116 ----
  953.   VAR( GC               Over_GC );        /* fg=blk, bg=wht, fcn=or */
  954.   VAR( GC               Reverse_GC );    /* fg=wht, bg=blk, fcn=copy */
  955.   VAR( GC               Xor_GC );        /* fg=blk, bg=wht, fcn=xor */
  956. + #undef VAR
  957. + #undef VARI
  958. *** ../dragon/tile.c    Tue May 23 00:03:57 1989
  959. --- tile.c    Mon May 22 23:55:46 1989
  960. ***************
  961. *** 122,129 ****
  962.   /*--Make sure that our caller is rational. */
  963.   
  964.       if (size < 1 || size > 5) {
  965. !     fprintf( stderr, "Bad size given to Configure_Tiles in tile.c [%d].\n",
  966. !          size );
  967.       size = 1;
  968.       }
  969.   
  970. --- 122,130 ----
  971.   /*--Make sure that our caller is rational. */
  972.   
  973.       if (size < 1 || size > 5) {
  974. !     (void)fprintf( stderr,
  975. !                "Bad size given to Configure_Tiles in tile.c [%d].\n",
  976. !                size );
  977.       size = 1;
  978.       }
  979.   
  980. ***************
  981. *** 201,207 ****
  982.   * Called to draw the number in the upper right corner of a numbered tile.
  983.   ******************************************************************************/
  984.   {
  985. !     XPutImage( XtDisplay(Board), XtWindow(Board), Over_GC, image,
  986.              0, 0, x + Number_X, y + Number_Y,
  987.              (unsigned int)image->width, (unsigned int)image->height );
  988.   } /* Draw_Number */
  989. --- 202,208 ----
  990.   * Called to draw the number in the upper right corner of a numbered tile.
  991.   ******************************************************************************/
  992.   {
  993. !     XPutImage( XtDisplay(Board), XtWindow(Board), Xor_GC, image,
  994.              0, 0, x + Number_X, y + Number_Y,
  995.              (unsigned int)image->width, (unsigned int)image->height );
  996.   } /* Draw_Number */
  997. No differences encountered
  998.